//
//  UIView+Chained.m
//  Express
//
//  Created by lhongl on 2025/10/11.
//  Copyright © 2025 QM. All rights reserved.
//

#import "UIView+Chained.h"

@implementation UIView (Chained)

+ (__kindof UIView *)mg_initWithMake:(void(^)(__kindof UIView *make))block{
    UIView *view = [[self alloc] init];
    if (block) {
        block(view);
    }
    return view;
}

- (__kindof UIView *)mg_make:(void(^)(__kindof UIView *make))block{
    if (block) {
        block(self);
    }
    return self;
}

- (__kindof UIView *(^)(UILayoutPriority priority))mg_horizontalPriority{
    return ^(UILayoutPriority priority){
        [self setContentHuggingPriority:priority forAxis:UILayoutConstraintAxisHorizontal];
        [self setContentCompressionResistancePriority:priority forAxis:UILayoutConstraintAxisHorizontal];
        return self;
    };
}
- (__kindof UIView *(^)(UILayoutPriority priority))mg_verticalPriority{
    return ^(UILayoutPriority priority){
        [self setContentHuggingPriority:priority forAxis:UILayoutConstraintAxisVertical];
        [self setContentCompressionResistancePriority:priority forAxis:UILayoutConstraintAxisVertical];
        return self;
    };
}

@end
